package com.zhu.day.util;

import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.WeekFields;
import java.util.Locale;
import java.util.Objects;

public class WeekUtils {


    /**
     * 获取当前是一年的第?周
     *
     * @param localDateTime
     * @return
     */
    public static int getWeekOfYear(LocalDateTime localDateTime) {
        if (Objects.isNull(localDateTime)) {
            localDateTime = LocalDateTime.now();
        }
        LocalDate localDate = localDateTime.toLocalDate();
        WeekFields weekFields = WeekFields.of(DayOfWeek.MONDAY, 1);
        int weekOfYear = localDate.get(weekFields.weekOfYear());
        return weekOfYear;
    }

    public static void main(String[] args) {
//        LocalDateTime localDateTime = LocalDateTime.parse("2021-06-21T00:23:59");
//        System.out.println(getWeekOfYear(localDateTime));
//
//        long m = -5;
//        long n = 4;
//        long init  = m;
//        long initN  = Math.abs(n);
//        System.out.println(Math.pow(m,n));
//
//        int i = 1;
//        while (i<initN){
//            m = m*init;
//            i++;
//        }
//        System.out.println(m);

//        String a = "xx";
//        Preconditions.checkState(!StringUtils.isNoneBlank(a));
        String json = "{\n" +
                "    \"13140000\":{\n" +
                "        \"speakCardMap\":{\n" +
                "            \"1\":{\n" +
                "                \"id\":\"1594955509962:601\"\n" +
                "            },\n" +
                "            \"2\":{\n" +
                "                \"id\":\"1594955509962:602\"\n" +
                "            },\n" +
                "            \"3\":{\n" +
                "                \"id\":\"1594955509962:603\"\n" +
                "            }\n" +
                "        },\n" +
                "        \"effectsMap\":{\n" +
                "            \"1\":{\n" +
                "                \"templateUrl\":\"https://s.momocdn.com/w/u/others/2021/03/26/1616756323418-jinji.svga\",\n" +
                "                \"desc\":\"晋级\",\n" +
                "                \"text\":\"恭喜%s晋级\"\n" +
                "            }\n" +
                "        },\n" +
                "        \"privilegeMap\":{\n" +
                "            \"1\":{\n" +
                "                \"id\":\"282\",\n" +
                "                \"code\":\"10120\",\n" +
                "                \"level\":5\n" +
                "            }\n" +
                "        },\n" +
                "        \"flowCardNum\":0\n" +
                "    },\n" +
                "    \"52000000\":{\n" +
                "        \"speakCardMap\":{\n" +
                "            \"1\":{\n" +
                "                \"id\":\"1594955509962:601\"\n" +
                "            },\n" +
                "            \"2\":{\n" +
                "                \"id\":\"1594955509962:602\"\n" +
                "            },\n" +
                "            \"3\":{\n" +
                "                \"id\":\"1594955509962:603\"\n" +
                "            }\n" +
                "        },\n" +
                "        \"effectsMap\":{\n" +
                "            \"1\":{\n" +
                "                \"templateUrl\":\"https://s.momocdn.com/w/u/others/2021/03/26/1616756323418-jinji.svga\",\n" +
                "                \"desc\":\"晋级\",\n" +
                "                \"text\":\"恭喜%s晋级\"\n" +
                "            }\n" +
                "        },\n" +
                "        \"privilegeMap\":{\n" +
                "            \"1\":{\n" +
                "                \"id\":\"282\",\n" +
                "                \"code\":\"10120\",\n" +
                "                \"level\":5\n" +
                "            }\n" +
                "        },\n" +
                "        \"flowCardNum\":0\n" +
                "    },\n" +
                "    \"99000000\":{\n" +
                "        \"speakCardMap\":{\n" +
                "            \"1\":{\n" +
                "                \"id\":\"1594955509962:601\"\n" +
                "            },\n" +
                "            \"2\":{\n" +
                "                \"id\":\"1594955509962:602\"\n" +
                "            },\n" +
                "            \"3\":{\n" +
                "                \"id\":\"1594955509962:603\"\n" +
                "            }\n" +
                "        },\n" +
                "        \"effectsMap\":{\n" +
                "            \"1\":{\n" +
                "                \"templateUrl\":\"https://s.momocdn.com/w/u/others/2021/03/26/1616756323418-jinji.svga\",\n" +
                "                \"desc\":\"晋级\",\n" +
                "                \"text\":\"恭喜%s晋级\"\n" +
                "            }\n" +
                "        },\n" +
                "        \"privilegeMap\":{\n" +
                "            \"1\":{\n" +
                "                \"id\":\"282\",\n" +
                "                \"code\":\"10120\",\n" +
                "                \"level\":5\n" +
                "            }\n" +
                "        },\n" +
                "        \"flowCardNum\":1\n" +
                "    }\n" +
                "}";

        System.out.println(json);

    }
}
